#pragma once

#include "HItemManager.h"
#include "GameItem.h"

namespace BombBox
{
	class GameItem_Box;

	class BoxItem : public ItemListener, public GameItem
	{
	public:
		BoxItem( GameItem_Box* pBox );
		~BoxItem( void );
	public:
		virtual int getType();
		virtual bool doDamage( int nDamage );

	public:
		void setItemController( ItemController* pItemController );
		ItemController* getItemController( void ) { return m_pItemController; }
		void setPosition( const irr::core::vector3df& vPos ){ m_vPos = vPos; }

	public:
		virtual const char* getItemName( void );
		virtual irr::core::stringc getItemMesh( int nStatus );
		virtual irr::core::stringc getItemPath( int nStatus );
		virtual bool getStatusAnimation( int nStatus );
		virtual int getAnimationSpeed( int nStatus );
		virtual void onAnimationStop( int nStatus );
		virtual bool enableLight( int nStatus );
		virtual const irr::core::vector3df& getPosition( int nStatus ) { return m_vPos; }

	protected:
		GameItem_Box*			m_pBox;

		int						m_nLife;
		irr::core::vector3df	m_vPos;
		ItemController*			m_pItemController;

		friend class GameItem_Box;
	};

	class GameItem_Box
	{
	public:
		GameItem_Box(void);
		~GameItem_Box(void);

	public:
		void onItemPicked( void );

	public:
		void setLife( int nlife );
		void setPath( irr::core::stringc sPath );
		void setID( int nID );
		void addStatus( int nValue, irr::core::stringc sFile );

	public:
		BoxItem* createInstance( void );
	
	public:
		int getID( void );
		irr::core::stringc getFilePath( void );
		irr::core::stringc getStatusFile( int nStatus );

	protected:
		irr::core::stringc	m_sFilePath;
		irr::core::map<int,irr::core::stringc>	m_vBoxStatus;

		int		m_nLife;
		int		m_nID;


		friend class GameItem_Box;
	};

#define s_pBoxesManager (BombBox::BoxesManager::getSingletonPtr())


	class BoxesManager : public OSLib::Singleton<BoxesManager>
	{
	public:
		BoxesManager();
		~BoxesManager();

	public:
		void loadConfig( irr::core::stringc sFile );
		GameItem_Box* registerBox( int nTypeID );

	public:
		BoxItem* createBox( int nTypeID );


	protected:
		irr::core::map<int,GameItem_Box*>	m_vBoxes;

	};

}